package com.zhou.cloud.util;

/**
 * @descrition: uuid工具类
 * @author: zhouyongjun
 * @date: 2022/10/28
 **/
public final class UuidUtil {

    public static Long defaultMaxTimeOffset(){
        return bitStringToLong(15);
    }


    public static Long defaultMaxZoneId(){
        return bitStringToLong(13);
    }


    public static Long defaultMaxIncrement(){
        return bitStringToLong(35);
    }

    /**
    * @Description: 二进制string转换成long类型
    * @Params:
     *  bitLen 二进制长度
    * @Returns:
    * @Author: zhouyongjun
    * @Date Created in 2022/11/1 8:55
     */
    public static Long bitStringToLong(int bitLen){
        return Long.parseLong(maxBitString(bitLen),2);
    }
    public static String maxBitString(int bitLen) {
        StringBuilder sb = new StringBuilder();
        for (int i=0;i<bitLen;i++){
            sb.append("1");
        }
        return sb.toString();
    }

}
